package com.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LogoutFilter extends HttpServlet implements Filter {

	private static final long serialVersionUID = 1L;

	public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
		HttpServletRequest   req  =  (HttpServletRequest)request;
		HttpServletResponse res   =  (HttpServletResponse)response;
		Object  username = req.getSession().getAttribute("username");
		String  url   =  req.getRequestURI();
		StringBuffer  sb  = new  StringBuffer(url);
		int i  = 0 ;
		if(sb.reverse().substring(0, 8).equals("login.jsp")){
			
		}
		//if(url.su)
		System.out.println(url);
		/**if(username == null){
			res.sendRedirect("login.jsp");
		}
		if(username!=null&&username.toString().equals("")){
			res.sendRedirect("login.jsp");
		}*/
	}

	public void init(FilterConfig arg0) throws ServletException {
		
	}

}
